package 力扣算法练习.main1.newPart1;

import java.util.Arrays;

public class day10 {
    //https://www.nowcoder.com/practice/a5190a7c3ec045ce9273beebdfe029ee?tpId=122&tqId=33661&ru=/exam/oj

    public void Lucky(int len,int[] temp){

        Arrays.sort(temp);

        System.out.println(findLucky(temp,len,0,0,1));
    }
    public int  findLucky(int [] temp,int len,int pos,int sum,int multi){
        int count=0;
        for (int i = pos; i <len ; i++) {
            sum+=temp[i];
            multi*=temp[i];
            if (sum>multi){
                count=count+1+findLucky(temp,len,i+1,sum,multi);
            }else if(temp[i]==1){
                count+=findLucky(temp,len,i+1,sum,multi);
            }else{
                break;
            }
            sum-=temp[i];
            multi/=temp[i];
            //排除相同的球
            while(i<len-1&&temp[i]==temp[i+1]){
                i++;
            }

        }
        return count;
    }

    public static void main(String[] args) {
        day10 iu=new day10();
        int[] t={1,1,1};
        iu.Lucky(3,t);
    }
}
